<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script type="text/javascript" src="js/jsAddress.js"></script>
  <title>e网批发管理后台</title>
  <?php 
  include("common/conn.php");  
  include("./tool/UpFileTool.class.php");
  if($_GET['action']=="ok")
  {    
if ($_FILES) {
  $UpFileTool=new UpFileTool('upfile');
  $UpFileTool->sumbImage($w=500, $h=500);
  $UpFileTool->upFile();
  $images = $UpFileTool->sumbImage;
  $srcimages = $UpFileTool->srcImage;
}

$date=date("Y-m-d h:i:s");

$srat=mysql_query("INSERT INTO user(niname,sex,money,phone,images,srcimages,tel,province,city) VALUES ('$_REQUEST[niname]','$_REQUEST[sex]','$_REQUEST[money]','$_REQUEST[phone]','$images','$srcimages','$_REQUEST[tel]','$_REQUEST[province]','$_REQUEST[city]')");

$dingid=mysql_insert_id();

$srat=mysql_query("INSERT INTO guanli(shopid,userid) VALUES ('$_POST[shopid]','$dingid')");



echo "<script>window.location.href='user.php';</script>";
}

if($_GET['id']!=""){

  $rert36=mysql_query("select * from user where  userid = '".$_GET['id']."'");
  $sdg37=mysql_fetch_array($rert36);

  $rert37=mysql_query("select * from shop  where  shopid = '".$sdg35[shopid]."'");
  $sdg36=mysql_fetch_array($rert37);

}


if($_GET['ch']=="ok")
{    
$rert35=mysql_query("select * from user where userid='".$_REQUEST['id']."'");
$sdg35=mysql_fetch_array($rert35);

$srat1=mysql_query("update guanli set shopid='".$_POST['shopid']."' where id='".$_REQUEST['id']."'");
  $srat1=mysql_query("update user set niname='".$_POST['niname']."',sex='".$_POST['sex']."',money='".$_POST['money']."',phone='".$_POST['phone']."',tel='".$_POST['tel']."',province='".$_POST['province']."',city='".$_POST['city']."' where userid='".$sdg35['userid']."'");
if ($_FILES[upfile][tmp_name]!='') {
  $UpFileTool=new UpFileTool('upfile');
  $UpFileTool->sumbImage($w=500, $h=500);
  $UpFileTool->upFile();
  $images = $UpFileTool->sumbImage;
  $srcimages = $UpFileTool->srcImage;
  $srat1=mysql_query("update user set images='".$images."',srcimages='".$srcimages."' where userid='".$sdg35['userid']."'");
}




echo "<script>window.location.href='user.php';</script>";
}


?>
<script type="text/javascript" src="js/jquery.min.js"></script>

<!-- MASTER STYLESHEET-->
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<link href="css/style2.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript">
  <!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">



    </div>


  </div>

  <div class="container_12">
    <form action="addupuser.php?<?php if($_GET['id']!=""){echo "ch=ok";}else{echo "action=ok";} ?>" method="post" enctype="multipart/form-data"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="10%" scope="col"></td>
          <td width="40%" scope="col"><label>用户名称</label></td>
          <td width="50%" scope="col">
            <input name="niname" type="text" class="text" value="<?php echo $sdg37[niname];?>"/></td>
          </tr>
          <tr>
            <td width="10%" scope="col"></td>
            <td width="40%" scope="col"><label>性别</label></td>
            <td width="50%" scope="col">
              <select name="sex">
                <option value="1">男</option>
                <option value="0">女</option>
              </select>
            </td>
          </tr>
          <tr>
            <td width="10%" scope="col"></td>
            <td width="40%" scope="col"><label>金额</label></td>
            <td width="50%" scope="col">
              <input name="money" type="text" class="text" value="<?php echo $sdg37[money];?>"/></td>
            </tr>

             <tr>
               <td width="10%" scope="col"></td>
               <td width="40%" scope="col"><label>手机号</label></td>
               <td width="50%" scope="col">
                <input name="phone" type="text" class="text" value="<?php echo $sdg37[phone];?>"/></td>
              </tr>

              <tr>
                <td width="10%" scope="col"></td>
                <td width="40%" scope="col"><label>登陆密码</label></td>
                <td width="50%" scope="col"><input name="password" class="text" type="text"  value="<?php echo $sdg37[password];?>"/></td>
              </tr>
			  
			  
              <tr>
                <td width="10%" scope="col"></td>
                <td width="40%" scope="col"><label>头像</label><span style="font-size: 8px;font-weight: normal;color: black;">(请上传500*500像素大小的图片)</span></td>
                <td width="50%" scope="col">
                  <input name="upfile" type="file" class="text"/>
                  <?php if($_GET[id]!=""){?>
                  <img src="<?php echo $sdg37[images];?>" width="100" height="100"/><?php }?>
                </td>
              </tr>

              <tr>
                <td width="10%" scope="col"></td>
                <td width="40%" scope="col"><label>固定电话</label></td>
                <td width="50%" scope="col"><input name="tel" class="text" type="text"  value="<?php echo $sdg37[tel];?>"/></td>
              </tr>

              <tr>
                <td width="10%" scope="col"></td>
                <td width="40%" scope="col"><label>省份</label></td>
                <td width="50%" scope="col"><input name="province" class="text" type="text"  value="<?php echo $sdg37[province];?>"/></td>
              </tr>


              <tr>
                <td width="10%" scope="col"></td>
                <td width="40%" scope="col"><label>城市</label></td>
                <td width="50%" scope="col"><input name="city" class="text" type="text"  value="<?php echo $sdg37[city];?>"/></td>
              </tr>

              <tr>
                <td width="10%" scope="col"></td>
                <td width="40%" scope="col"></td>
                <td width="50%" scope="col"><input name="id" type="hidden" value="<?php echo $_GET[id];?>" />
                  <input name="" type="submit" value="提交" class="submit" /></td>
                </tr>




              </table>
            </form>    

          </div>

          <!-- end content wrap -->

        </form>


      </body>
      </html>


